import {ColumnsType} from "antd/es/table";
import {SecurityUserType} from "../type/SecurityUser";
import {Link} from "react-router-dom";
import {createAction, ellipsisHandler, getUserStatuesTag} from "../util/ColumnsUtil";

const userColumns: ColumnsType<SecurityUserType> = [
    {
        dataIndex: 'index',
        title: '序号' ,
        width: 60,
        align: "center" ,
        render: (value, record, index) => {
            return <strong> {index + 1} </strong> ;
        }
    },
    {
        key: 'id',
        dataIndex: 'id' ,
        title: '用户编号',
        width: 110,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'username',
        dataIndex: 'username' ,
        title: '用户名',
        width: 120,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: (_,record)=> {
            return <Link to={"./details"} state={record}>{record.username}</Link> ;
        }
    },
    {
        key: 'identity',
        dataIndex: 'identity' ,
        title: '用户身份',
        width: 120,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'status',
        title: '用户状态',
        dataIndex: 'enabled' ,
        width: 105,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: getUserStatuesTag
    },
    {
        key: 'order',
        dataIndex: 'order' ,
        title: '数据排序',
        width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'remark',
        dataIndex: 'remark' ,
        title: '备注信息',
        // width: 100,
        align: "center" ,
        ellipsis: {showTitle: false},
        render: ellipsisHandler
    },
    {
        key: 'option',
        title: '用户操作',
        dataIndex: 'option' ,
        align: "center",
        width: 170,
        render: createAction
        // render: (_, record) => {
        //     return (
        //         <Space size={8}>
        //             <Link key={"user-update"} to={'./update/' + record.id}>更新</Link>
        //             <Link key={"user-authority"} to={'./authority'} state={record}>授权</Link>
        //             <Popconfirm title={`是否要确认删除${record.username}?`} onConfirm={() => {
        //                 deleteDataById(record.id, "/security-user")
        //                     .then(res => res && executeDispatch<number>("UserColumns",deleteUserById(record.id))) ;
        //             }}>
        //                <Button key={"user-delete"} size={"small"} type={"primary"} danger>删除</Button>
        //             </Popconfirm>
        //         </Space>
        //     ) ;
        // }
    }
    ];


export default userColumns ;